package StudyCode.summary.myfile;

import java.io.*;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CopyStream {

	public static void main(String[] args) throws FileNotFoundException {

		copyStream(new FileInputStream("E:\\迅雷下载\\test1.txt"), new FileOutputStream("E:\\Copy\\test1.txt"));
	}

	private static void copyStream(InputStream is, OutputStream os) {
		final int buffer_size = 1024;
		try {
			byte[] bytes = new byte[buffer_size];
			for (; ; ) {
				int count = is.read(bytes, 0, buffer_size);
				if (count == -1)
					break;
				os.write(bytes, 0, count);
			}
			System.out.println("复制成功。");
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}
